-
-
Notifications
You must be signed in to change notification settings - Fork 154
GH1488 Add overload for DataFrame.max when axis is None #1490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
/pandas_nightly |
cmp0xff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding mean, min, median. I think we just need to relax the type testing.
| skipna: _bool | None = True, | ||
| numeric_only: _bool = False, | ||
| **kwargs: Any, | ||
| ) -> Scalar: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably further restrict to _OrderableT from pandas-stubs/_libs/intervals.pyi, instead of just Scalar. But this can be done in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a type that can be returned? I thought it was more of a generic for Interval or something like that. I have left it for later.
tests/test_frame.py
Outdated
| df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]}) | ||
| check(assert_type(df.mean(), pd.Series), pd.Series) | ||
| check(assert_type(df.mean(axis=0), pd.Series), pd.Series) | ||
| check(assert_type(df.mean(axis=None), Scalar), np.float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we usually just test for the more generic np.floating unless there is a reason to test for the specific np.float64.
| check(assert_type(df.mean(axis=None), Scalar), np.float64) | |
| check(assert_type(df.mean(axis=None), Scalar), np.floating) |
tests/test_frame.py
Outdated
| df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]}) | ||
| check(assert_type(df.median(), pd.Series), pd.Series) | ||
| check(assert_type(df.median(axis=0), pd.Series), pd.Series) | ||
| check(assert_type(df.median(axis=None), Scalar), np.float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| check(assert_type(df.median(axis=None), Scalar), np.float64) | |
| check(assert_type(df.median(axis=None), Scalar), np.floating) |
tests/test_frame.py
Outdated
| df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]}) | ||
| check(assert_type(df.min(), pd.Series), pd.Series) | ||
| check(assert_type(df.min(axis=0), pd.Series), pd.Series) | ||
| check(assert_type(df.min(axis=None), Scalar), np.int64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| check(assert_type(df.min(axis=None), Scalar), np.int64) | |
| check(assert_type(df.min(axis=None), Scalar), np.integer) |
tests/test_frame.py
Outdated
| df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]}) | ||
| check(assert_type(df.max(), pd.Series), pd.Series) | ||
| check(assert_type(df.max(axis=0), pd.Series), pd.Series) | ||
| check(assert_type(df.max(axis=None), Scalar), np.int64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| check(assert_type(df.max(axis=None), Scalar), np.int64) | |
| check(assert_type(df.max(axis=None), Scalar), np.integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All addressed!
DataFrame.maxneeds the same overloads asDataFrame.anyhas #1488assert_type()to assert the type of any return value